#include<iostream>
#include<algorithm>
using namespace std;
const int N = 25;
char map[N][N];
bool st[N][N];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,1,0,-1 };
int ans;
int n, m;
void dfs(int x, int y)
{
	st[x][y] = 1;
	ans++;
	for (int i = 0; i < 4; i++) {
		int a = dx[i] + x;
		int b = dy[i] + y;
		if (st[a][b]==1)continue;
		if (a < 0 || a >= n || b < 0 || b >= m)continue;
		if (map[a][b] != '.')continue;
		dfs(a, b);
	}
}
int main()
{
	cin >> m >> n;
	int x = 0, y = 0;
	for (int i = 0; i < n; i++) {
		cin >> map[i];
		for (int j = 0; j < m; j++) {
			if (map[i][j] == '@') {
				x = i, y = j;
			}
		}
	}
	//cout << x << " " << y << endl;
	dfs(x, y);
	cout << ans << endl;
	return 0;
}